
import org.springframework.beans.factory.annotation.Value;


@Component
@Slf4j
public class LoginCheckInterceptor implements HandlerInterceptor {

    // 从配置文件中读取环境变量，避免硬编码
    @Value("${spring.profiles.active:production}") // 默认为 production
    private String profile;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 如果是开发环境且请求路径为 /announcements，则跳过登录检查
        if ("development".equals(profile) && request.getRequestURI().startsWith("/announcements")) {
            return true;
        }

    }

}